package com.example.atte

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.alibaba.android.arouter.facade.annotation.Route
import com.baidu.location.BDAbstractLocationListener
import com.baidu.location.BDLocation
import com.baidu.location.LocationClient
import com.baidu.location.LocationClientOption
import com.baidu.mapapi.CoordType
import com.baidu.mapapi.SDKInitializer
import com.witmed.lib_base.App

@Route(path = "/atte/SignActivity")
class SignActivity : AppCompatActivity() {
    lateinit var location:LocationClient
    private lateinit var addressStr : String
    private var lat :Double=0.0
    private var longitude :Double=0.0
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_sign)
        SDKInitializer.initialize(App.baseApplication)
        SDKInitializer.setCoordType(CoordType.BD09LL)
        location= LocationClient(App.baseApplication)
        location.registerLocationListener(object :BDAbstractLocationListener(){
            override fun onReceiveLocation(p0: BDLocation?) {
                if (p0 == null)
                    location.start()
                if (p0!!.locType == 167){
                    addressStr = "天津"
                    return
                }
                addressStr = p0.address.address
                lat = p0.latitude
                longitude = p0.longitude
            }

        })
        val option = LocationClientOption()
        option.setIsNeedAddress(true)
        option.setCoorType("bd09ll")
        option.setEnableSimulateGps(true)
        location.locOption = option
        location.start()

    }
}